package xx.services.page.rest;

import java.sql.SQLException;

import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.core.Context;

import xx.entity.page.PageTabItemContent;
import xx.services.Passport;
import xx.services.page.inter.ITabItemContentInterface;
import xx.services.util.Constants;

/**
 * page页面tab列内容管理服务接口
 * 
 * @Path (Constants.RESTFUL_ROOT_PATH + "/page/tab/item/content")
 * 
 * @author dengjinye,2011-09-18
 * 
 * $LastChangedDate$ $Author$
 */
@Path(Constants.RESTFUL_ROOT_PATH + "/page/tab/item/content")
public class TabItemContentRest extends Passport implements ITabItemContentInterface
{

    public TabItemContentRest(@Context
    HttpServletRequest request)
    {
        super(request);
        // TODO Auto-generated constructor stub
    }

    @PUT
    @Path("/{link_id}/after/{after_id}")
    public String sortAfter(@PathParam("link_id")
    long linkId, @PathParam("after_id")
    long afterId)
    {
        try
        {
            PageTabItemContent ptic = new PageTabItemContent(qr,owner);
            ptic.setLinkId(linkId).after(afterId);
            return ok(true);
        }
        catch (SQLException e)
        {
            return error(e);
        }
    }

    @PUT
    @Path("/{link_id}/before/{before_id}")
    public String sortBefore(@PathParam("link_id")
    long linkId, @PathParam("before_id")
    long beforeId)
    {
        try
        {
            PageTabItemContent ptic = new PageTabItemContent(qr,owner);
            ptic.setLinkId(linkId).before(beforeId);
            return ok(true);
        }
        catch (SQLException e)
        {
            return error(e);
        }
    }

}
